#include <bits/stdc++.h>
using namespace std;
const int N = 10;
int n, k;
int st[N];
bool used[N];

void dfs(int u) {
    	if (u > k) {
            		for (int i = 1; i <= k; ++i) {
                        			cout << st[i] << ' ';
                    }
                    		cout << endl;
                            		return ;
        }
        	for (int i = 1; i <= n; ++i) {
                		if (!used[i]&&st[u-1]<i) {
                            			used[i] = true;
                                        			st[u] = i;
                                                    			dfs(u + 1);
                                                                			st[u] = 0;
                                                                            			used[i] = false;
                        }
            }
}

int main() {
    	cin >> n >> k;
        	dfs(1);
            	return 0;
}
}
                        }
            }
                    }
        }
}